package com.qgxy.spsave.utils;

import static android.content.Context.MODE_PRIVATE;

import android.content.Context;
import android.content.SharedPreferences;

import java.util.HashMap;
import java.util.Map;

public class SPSaveAccountPassword {

    public static boolean saveAccountPassword(Context context, String account, String password){

        SharedPreferences sp = context.getSharedPreferences("AccountAndPassword", MODE_PRIVATE);
        SharedPreferences.Editor editor = sp.edit();
        editor.putString("account", account);
        editor.putString("password", password);
        return editor.commit();
    }

    public static Map<String, String> getAccountPassword(Context context){

        Map<String, String> userInfoMap = new HashMap<>();

        SharedPreferences sp = context.getSharedPreferences("AccountAndPassword", MODE_PRIVATE);
        String account = sp.getString("account", "");
        String password = sp.getString("password", "");

        userInfoMap.put("account", account);
        userInfoMap.put("password", password);


        return userInfoMap;
    }

}
